﻿using DevExpress.XtraEditors;
using DevTeam;
using System;
namespace ConfExpert.Forms.Depo.Kauf
{
    public partial class DegerSetle : XPopupForm
    {
        string idxs;
        public DegerSetle(string idxs)
        {
            InitializeComponent();
            this.idxs = idxs;
        }

        private void DegerSetle_Load(object sender, EventArgs e)
        {
            
            textEdit1.Location = gridLookUpEdit1.Location;
            barButtonItem1.ItemClick += barButtonItem1_ItemClick;
            barButtonItem2.ItemClick += barButtonItem2_ItemClick;
            cmb.TextChanged += cmb_TextChanged;
            cmb.Text = "stGenelId";
        }

        void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            barButtonItem1.PerformClick();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        public bool updated = false;
        void cmb_TextChanged(object sender, EventArgs e)
        {
            gridLookUpEdit1.Visible = cmb.Text.EndsWith("Id");
            textEdit1.Visible = !cmb.Text.EndsWith("Id");
            gridLookUpEdit1.EditValue =
            textEdit1.EditValue = null;

            switch (cmb.Text)
            {
                case "stGenelId": gridLookUpEdit1.Properties.Assign(RI(Rp.stGenel)); break;
                case "BrandId": gridLookUpEdit1.Properties.Assign(RI(Rp.Brand)); break;
                case "SezonId": gridLookUpEdit1.Properties.Assign(RI(Rp.Sezon)); break;
                case "TalepTipiId": gridLookUpEdit1.Properties.Assign(RI(Rp.TalepTipi)); break;
                case "DagilimId": gridLookUpEdit1.Properties.Assign(RI(Rp.Dagilim)); break;
                //case "Notlar": gridLookUpEdit1.Properties.Assign(RI(Rp.stGenel)); break;
                //case "OrderRef": gridLookUpEdit1.Properties.Assign(RI(Rp.stGenel)); break;
                //case "Model": gridLookUpEdit1.Properties.Assign(RI(Rp.stGenel)); break;

            }
        }

        void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ExecuteNonQuery("UpdOrdersVal", idxs, cmb.Text, textEdit1.EditValue.ToStr(), gridLookUpEdit1.EditValue.ToInt());
            XtraMessageBox.Show("Güncellendi");
            updated = true;
        }
    }
}
